<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/v2/console/common/taglibs.jsp"%>
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="${path}/v2/console/css/base.css">
<link rel="stylesheet" href="${path}/v2/console/css/style.css">
<script src="${path}/v2/console/js/jquery-1.9.1.min.js"></script>
<script src="${path}/v2/console/js/globle.js"></script>
</head>
<body>
	<div id="wrapper">
		<div class="main">
			<div class="main-right">
				<div class="column-name">
					<h2>信息管理</h2>
				</div>
				<form id="pageForm" name="form" action="${pageContext.request.contextPath}/siteStaticinfo/siteStaticinfoList.html" method="post">
					<input type="hidden" name="type" value="${type}">
					<div class="main-top">
						<div class="fl">
							<a href="${pageContext.request.contextPath}/siteStaticinfo/toAddSiteStaticinfo.html?type=${type}" class="btn btn-p">新建</a>
						</div>
					</div>
					<div class="check">
						<div class="check-item">
							<span class="check-tit">状态:</span>
							<select class="input" name="status" >
								<option value="1" <c:if test="${status ==1}">selected="selected"</c:if> >已激活</option>
								<option value="0" <c:if test="${status ==0}">selected="selected"</c:if> >待激活</option>
								<option value="" <c:if test="${empty status}">selected="selected"</c:if>>全部</option>
							</select>
						</div>
						<div class="check-btn">
							<input type="submit" class="btn w96" value="查  询">
						</div>
				</div>
					<div class="content">
						<table class="table" width="100%" border="0" cellspacing="0"
							cellpadding="0">
							<thead>
								<tr>
									<th>名称</th>
									<th>图片</th>
									<th>链接</th>
									<th>状态</th>
									<th>创建时间</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${page.datasource}" var="data">
									<tr>
										<td>${data.name}</td>
										<td>
										<img alt="" src="${projectPath}${data.pic}" height="200" width="200">
										</td>
										<td>${data.url}</td>
										<td>
										<c:if test="${data.status ==1 }">已激活</c:if>
										<c:if test="${data.status ==0 }">未激活</c:if>
										</td>
										<td><fmt:formatDate value="${data.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
										<td>
											<a
										href="${pageContext.request.contextPath}/siteStaticinfo/toUpdateSiteStaticinfo.html?id=${data.id}"
										id="${data.id}" >修改</a> <a href="javascript:;"
										id="${data.id}" class="remove">删除</a>
										<c:if test="${data.status ==1 }">
											<a href="javascript:void(0);" id="${data.id}" onclick="pub(${data.id},0)">取消激活</a>
										</c:if>
										<c:if test="${data.status ==0 }">
											<a href="javascript:void(0);" id="${data.id}" onclick="pub(${data.id},1)">激活</a>
										</c:if>
										</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
						<div id="page">
							<%@ include file="/v2/console/common/pageView.jsp"%>
						</div>
					</div>
				</form>
				
				</div>

		<div class="popBox remove-pop">
			<div class="popBox-back"></div>
			<div class="popBox-box">
				<div class="popBox-con">
					<div class="remove-con">
						<div class="tit">你确定要删除吗？</div>
						<div class="btns">
							<a href="javascript:;" class="btn w144">删 除</a> <a
								href="javascript:;" class="btn-gray w144">取 消</a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
			$(function(){
				remove();// 删除弹出框
				quxiao();// 弹出框s
			});
		
			// 删除
			function remove(){
				$('.remove').click(function() {
					$('.remove-pop').show();
					$('.remove-pop .btn').attr({'href': '${pageContext.request.contextPath}/siteStaticinfo/delSiteStaticinfo.html?type=${type}&id='+this.id});
				});	
			}
			// 弹出框
			function quxiao(){
				var $btn = $('.popBox').find('.btn-gray');
				$btn.click(function() {
					$('.popBox').hide();
				});
			}
		
			function pub(ids,v){
				$.ajax({
					type : "post",
					url : "${path}/siteStaticinfo/pub.html",
					dataType : "json",
					data:{id:ids,value:v},
					async : false,
					success : function(data) {
						if(data.ajax_status == "ajax_status_success"){
							 $("#pageForm").submit();
						}else{
							alert(data.msg);
						}
						return false;
					},
					error : function(XMLHttpRequest, textStatus, errorThrown){
			          alert("出错了！");
			       }
				});
			}
	</script>
</body>
</html>